<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
</head>

<body>
    <div id='app'>
        {{msg}}
        <form action="">
            <input type="text" v-model.number='a'>
            <select name="" id="" v-model='opt'>
                <option value='+'>+</option>
                <option value='-'>-</option>
                <option value='*'>*</option>
                <option value='/'>/</option>
            </select>
            <input type="text" v-model.number='b'>
            <input type="button" value="=" @click='tatal'>
            <span>{{sub}}</span>
        </form>
        =={{opt}}==
    </div>
    <script type='text/javascript'>
        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue',
                opt: '-',
                a: 1,
                b: 2,
                sub: 3
            },
            methods: {
                tatal() {
                    console.log(this.opt, 8888);
                    // if (this.opt == '+') {
                    //     this.sub = this.a + this.b
                    // } else if (this.opt == '-') {
                    //     this.sub = this.a - this.b
                    // } else if (this.opt == '*') {
                    //     this.sub = this.a * this.b
                    // } else {
                    //     this.sub = this.a / this.b
                    // }

                    switch (this.opt) {
                        case '+':
                            this.sub = this.a + this.b
                            break;
                        case '-':
                            this.sub = this.a - this.b
                            break;
                        case '*':
                            this.sub = this.a * this.b
                            break;
                        case '/':
                            this.sub = this.a / this.b
                            break;
                    }
                }
            }
        });
    </script>
</body>

</html>